package com.nd.mobile.study.domain;

import java.io.Serializable;
import java.lang.reflect.Type;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;

public class VideoInfo implements Serializable{

	private static final long	serialVersionUID	= 1L;

	@SerializedName("SVRID")
	private String id;
	
	@SerializedName("SubjectResName")
	private String name;
	
	@SerializedName("SubjectResPicUrl")
	private String resPicURL;
	
	@SerializedName("SubjectResUrl")
	private String resURL;
	
	@SerializedName("ResDescription")
	private String resDescription;

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getResPicURL() {
		return resPicURL;
	}

	public String getResURL() {
		return resURL;
//		return "http://pic1.up.91img.com/edu_bbs_static/201105271801480006_13_480x320.mp4";
	}

	public String getResDescription() {
		return resDescription;
	}
	
	public boolean submitTime(User user, long millsecond) throws Exception {
		Bundle data = new Bundle();
		data.putString(ReqParam.COMMON_USER_ID, user.getUserId());
		data.putString(ReqParam.VIDEO_ID, id);
		data.putLong(ReqParam.VIDEO_RESUMING_TIME, millsecond);
		String jsonData = HttpRequestUtil.get(Commands.SUBMIT_SUBJECT_VIDEO_TIME, data);
		Gson gson = new Gson();
		Type type = new TypeToken<Result<String>>(){}.getType();
		Result<String> result = gson.fromJson(jsonData, type);
		return "1".equals(result.getBody());
	}
	
}
